# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=polyml
pkgver=5.9.1
pkgrel=0
pkgdesc="ML97 compatible Standard ML implementation"
url="https://www.polyml.org/"
# x86: https://github.com/polyml/polyml/issues/193
arch="all !x86"
license="LGPL-2.1-only"
makedepends="gmp-dev libffi-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/polyml/polyml/archive/v$pkgver.tar.gz
	riscv64.patch"

build() {
	# Compiling poly as a dynamically linked position independent
	# executable causes it to segfault. Since Alpine's GCC enables
	# PIE by default we need to explicitly disable it.
	#
	# See https://github.com/polyml/polyml/issues/111
	CFLAGS="$CFLAGS -no-pie" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-gmp
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
e471abef01b7f2bfac6d847904c0fcef6ae5a1356b1246a2e8982d24fd590b49feb03752642efe09d34344b4faf89bc3edd4418e9993e72ea22e5482e6d37271  polyml-5.9.1.tar.gz
bf41a055b01ca9e5d1856e39f318079e23272eb034031cb97f7b7dbb94b981b6956baaba38d33c959e2175f052d4214dffd6f1fb18a69b8509013a19a93beb50  riscv64.patch
"
